﻿using System;
using Assist;
using Autodesk.Revit.DB;

namespace ArchPostprocessing.RoomDecorate
{
	internal class DrawSkirtline
	{
		public DrawSkirtline(Autodesk.Revit.DB.Document doc)
		{
			this.m_doc = doc;
		}

		public bool CreateSkirtlineWallType(WallType wallType, Autodesk.Revit.DB.ElementType eleTypeSweep, bool bOnOutside, double dSkirtBottomHigh)
		{
			CompoundStructure compoundStructure = wallType.GetCompoundStructure();
			if (compoundStructure == null)
			{
				return false;
			}
			WallSweepInfo wallSweepInfo = new WallSweepInfo(true, 0);
			double dHorOffset = 0.0;
			double dVerOffset = AssistFunc.mmToFeet(dSkirtBottomHigh);
			DrawSkirtline.SetWallSweepInfo(wallSweepInfo, dHorOffset, dVerOffset, bOnOutside);
			FamilySymbol familySymbol = eleTypeSweep as FamilySymbol;
			if (familySymbol == null)
			{
				return false;
			}
			wallSweepInfo.ProfileId = familySymbol.Id;
			wallSweepInfo.Id = 101;
			compoundStructure.AddWallSweep(wallSweepInfo);
			wallType.SetCompoundStructure(compoundStructure);
			return true;
		}

		public static void SetWallSweepInfo(WallSweepInfo wallSweepInfo, double dHorOffset, double dVerOffset, bool bOnOutside)
		{
			if (bOnOutside)
			{
                wallSweepInfo.WallSide = (WallSide)0;
			}
			else
			{
                wallSweepInfo.WallSide = (WallSide)1;
			}
			wallSweepInfo.DistanceMeasuredFrom = 0;
			wallSweepInfo.Distance = dVerOffset;
			wallSweepInfo.Id = -1;
			wallSweepInfo.WallOffset = dHorOffset;
		}

		private Document m_doc;
	}
}
